﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace LiveWCFServiceTests
{
    [TestClass]
    public class ALoginServiceTest:ServiceTestBase<LoginServiceRef.LoginServiceClient>
    {
        
        [TestMethod]
        public void CheckAuthenticationService()
        {
            ATestWithInvalidLogin();
            BTestWithValidLogin();
        }
        public void ATestWithInvalidLogin()
        {
            Assert.IsFalse(Client.IsLoggedIn());
            var LoginResult = Client.Login("User", "Password", "CustomCred", false);
            Assert.IsTrue(LoginResult.Success, LoginResult.FailureMessage);
            Assert.IsFalse(LoginResult.Value);
            Assert.IsFalse(Client.IsLoggedIn());
        }
        public void BTestWithValidLogin()
        {
            var client = Client;
            var LoginResult = client.Login(TestConfiguration.Username, TestConfiguration.Password, "", false);

            Assert.IsTrue(LoginResult.Success, LoginResult.FailureMessage);
            Assert.IsTrue(LoginResult.Value);
            Assert.IsTrue(Client.IsLoggedIn());
        }

        protected override string ServiceLocation
        {
            get { return "Services/LoginService.svc"; }
        }
    }
}
